<?php

use yii\db\Migration;

/**
 * Handles the creation of table `goods`.
 */
class m181206_055543_create_product_table extends Migration
{
    /**
     * {@inheritdoc}
     */
    public function safeUp()
    {

        $tableOptions = null;
        if ($this->db->driverName === 'mysql') {
            $tableOptions = 'CHARACTER SET utf8 COLLATE utf8_general_ci ENGINE=InnoDB';
        }
        $this->createTable('{{%product}}', [
            'id' => $this->primaryKey(),
            'ttid' => $this->string(255)->comment("商品ID"),
            'name' => $this->string(255)->notNull()->comment("商品名称"),
            'price' => $this->DECIMAL(10,2)->notNull()->comment("原价"),
            'newprice' => $this->DECIMAL(10,2)->notNull()->comment("新价格"),
            'image' => $this->string(255)->comment('商品图片'),
            'coupon_id' => $this->smallInteger(3)->notNull()->comment(' 优惠券id'),
            'description' => $this->string(255)->comment('拼团和参团进行中页面文案'),
            'remark'=>$this->text()->comment("商品描述"),
            'notes'=>$this->text()->comment("注"),
            'share_title'=>$this->string(255)->comment("微信分享标题"),
            'share_img'=>$this->string(255)->comment("微信分享图片"),
            'share_txt'=>$this->string(255)->comment("微信分享文案"),
            'share_url'=>$this->string(255)->comment("微信分享连接"),
            'activity_id'=>$this->integer(5)->comment("活动ID"),

        ],$tableOptions);
        return true;
    }

    /**
     * {@inheritdoc}
     */
    public function safeDown()
    {
        $this->dropTable('{{%product}}');
        return true;
    }
}
